#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(long x)
    : _base(x)
    {
        cout << "Base()" << endl;
    }
    
    void print(int x) const{
        cout << "Base::_base:" << _base << endl;
        cout << "Base::_data:" << _data  << endl;
    }
    
    long _data = 100;
private:
    long _base;
};

class Derived
: public Base
{
public:
    Derived(long base,long derived)
    : Base(base)//创建基类子对象
    , _derived(derived)
    {
        cout << "Derived()" << endl;
    }
    
    int print(int x) const{
        cout << "Derived::_data:" << _data  << endl;
        return x;
    }

    long _data = 19;
private:
    long _derived;

};

void test0(){
    Derived dd(1,2);
    //当派生类定义了与基类同名的数据成员
    //那么对基类的这个数据成员形成了隐藏
    cout << dd._data << endl;
    cout << dd.Base::_data << endl;
    cout << dd.print(1) << endl; 
    dd.Base::print(1);
    cout << "sizeof(Derived):" << sizeof(Derived) << endl;
}

int main(void){
    test0();
    return 0;
}
